package shapes;

import java.awt.Graphics;
import java.util.Vector;

/**
 * <p>Title: Project 12 - Shape class</p>
 * <p>Description: CS 235 Project #12
 *       Used to store a group of Shape objects
 *       Used for looking at preconditions, postconditions, asserts, javadoc.</p>
 * @author Anthony Varghese
 * @date   February 5th 2012
 * @version 1.0
 */

public class ShapeCart {
	/**
	 * Data members
	 * The xstart, ystart, xend, and yend specify the position of this ShapeCart.
	 */
	private int xstart;
	private int ystart;
	private int xend;
	private int yend;
	private Vector<Shape> cart;
	
	/**
	 * Constructor - ShapeCart
	 *  
	 * 
	 * @require 
	 * 
	 * @ensure
	 * 
	 */
	public ShapeCart(){
		cart = new Vector<Shape>();
	}

	/**
	 * Constructor - ShapeCart
	 * @param xs
	 * @param ys
	 * @param xe
	 * @param ye
	 * 
	 * @require 
	 * 
	 * @ensure
	 * 
	 */
	public ShapeCart(int xs, int ys, int xe, int ye) {
		xstart = xs;
		ystart = ys;
		xend   = xe;
		yend   = ye;
		cart = new Vector<Shape>();
	}

	/**
	 * add - add a new shape to the cart
	 *  
	 * @param shape
	 * 
	 * @require 
	 * 
	 * @ensure
	 * 
	 */
	public void add(Shape shape) {
		cart.add( shape );
	}

	/**
	 * draw - draw the shape
	 * 
	 * @param graphics
	 * 
	 * @require 
	 * 
	 * @ensure
	 * 
	 */
	public void draw(Graphics graphics) {
		
		if (cart.isEmpty())
			return;

		for (Shape s : cart)
			if (s != null)
				s.draw(graphics);
	}
	
	/**
	 * Getters
	 */
	public int getXstart() {
		return xstart;
	}

	public int getYstart() {
		return ystart;
	}

	public int getXend() {
		return xend;
	}

	public int getYend() {
		return yend;
	}
}